﻿using System.Collections.Generic;
using System.Linq;
using Iesi.Collections.Generic;

namespace Golf.Core
{
    public class Course : BusinessObjectBase
    {
        public Course()
        {
            Holes = new HashedSet<Hole>();
        }

        public Course(int id) : this()
        {
            Id = id;
        }

        public string Name { get; set; }
        public string Venue { get; set; }
        public County County { get; set; }
        public IEnumerable<Hole> Holes { get; set; }

        public int Par
        {
            get
            {
                return (from hole in Holes select hole.Par).Sum();
            }
        }

        public int Yardage
        {
            get
            {
                return (from hole in Holes select hole.Yardage).Sum();
            }
        }

        public override string ToString()
        {
            return Name;
        }
    }
}
